package com.huayi.datagovernance.schedule;

import com.huayi.datagovernance.common.SysConstant;
import com.huayi.datagovernance.service.LxTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.format.DateTimeFormatter;

/**
 * 定时任务
 * @author wuch
 * @version 1.0
 * @date 2021/3/29 17:50
 */
@Component
@Slf4j
public class ScheduledTask {
    //格式化
    private DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @Resource
    private LxTaskService lxTaskService;
    /**
     * 每5分钟同步朗新工单
     * 0 0 1 * * ?
     */
//    @Scheduled(cron = "0 0/5 * * * ?")//5分钟
    @Scheduled(cron = "0 0/1 * * * ?")//1分钟
//    @Scheduled(cron = "0/5 * * * * ?")//5秒
    public void fetchWorkOrderFromLx() {
//        log.info("==============开始获取朗新工单，时间：{}==============",LocalDateTime.now().format(dtf));
        lxTaskService.fetchWorkOrderFromLx(SysConstant.TASK_STATE_YK);//业扩
        lxTaskService.fetchWorkOrderFromLx(SysConstant.TASK_STATE_HIGH_CHECK);//高压
//        log.info("==============同步朗新工单完毕==============");
    }
}
